package com.example.xm.controller;

import com.example.xm.entity.Orderentity;
import com.example.xm.entity.dto.OrderDto;
import com.example.xm.entity.dto.OrderListDto;
import com.example.xm.entity.vo.OrderListVo;
import com.example.xm.service.OrderService;
import com.example.xm.web.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    OrderService orderService;
    @PostMapping("/add")
    public Result add(@RequestBody OrderDto orderDto){
        orderService.add(orderDto);
        return Result.success();
    }
    @GetMapping("/list")
    public Result list(OrderListDto dto){
        PageInfo list= orderService.list(dto);
        return Result.success(list);
    }
    @GetMapping("/changeStatus")
    public Result changeStatus(Integer id,Integer status){
        orderService.changeStatus(id,status);
        return Result.success();
    }
    @GetMapping("/update")
    public Result update(Orderentity orderentity){
        orderService.update(orderentity);
        return Result.success();
    }

}
